package ch.selise.exercise.pattern.notepad.command.impl;

import ch.selise.exercise.pattern.notepad.command.CommandExecutor;
import ch.selise.exercise.pattern.notepad.command.ICommand;
import ch.selise.exercise.pattern.notepad.command.IUndoableCommand;
import ch.selise.exercise.pattern.notepad.command.StackManipulator;
import ch.selise.exercise.pattern.notepad.exception.EmptyStackException;
import ch.selise.exercise.pattern.notepad.exception.ExecuteException;
import ch.selise.exercise.pattern.notepad.storage.AppStorageSingleton;

public class UndoCommand implements ICommand {
	
	//private CommandExecutor ce;
	//IUndoableCommand command;
	StackManipulator stackManipulator;
	
	public UndoCommand(StackManipulator stackManipulator)
	{
		//this.command = command;
		this.stackManipulator = stackManipulator;
	}
	@Override
	public void execute() throws ExecuteException {
		try {
			stackManipulator.undoCommand();
		} catch (EmptyStackException e) {
			throw new ExecuteException(e);
		}

	}

}
